package com.sharp.socket.io.dao.msyql.repository;

import com.sharp.kernel.constant.CommonConst;
import com.sharp.kernel.mybatis.repository.BaseMysqlRepository;
import com.sharp.socket.io.dao.msyql.entity.ChatRoomFriend;
import com.sharp.socket.io.dao.msyql.mapper.ChatRoomFriendDao;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * Title: ChatRoomFriendService
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2022/6/17 14:35
 */
@Service
public class ChatRoomFriendService extends BaseMysqlRepository<ChatRoomFriend, ChatRoomFriendDao> {

    @Resource
    private ChatRoomFriendDao chatRoomFriendDao;

    public List<ChatRoomFriend> getFriendByUserId(String userId) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId", userId);
        criteria.andEqualTo("confirm", CommonConst.YES);
        return super.select(example);
    }

    public List<ChatRoomFriend> getUnconfirmedFriendByUserId(String userId) {
        Example example = super.getExample();
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId", userId);
        criteria.andIsNull("confirm");
        return super.select(example);
    }

}
